package com.cloudlinkscm.loms.services.base.notify.dto.email.builder.component;

import com.cloudlinkscm.loms.services.base.notify.dto.email.EmailMessageDto;
import com.cloudlinkscm.loms.services.base.notify.dto.email.builder.EmailMessageDtoBuilder;
import com.cloudlinkscm.loms.services.base.notify.dto.email.builder.EmailMessageDtoBuilderDecorator;
import org.joda.time.DateTime;

import java.util.Date;

/**
 * @author : tac
 * @date : 2017/7/12
 */
public class EmailMessageDtoSendDateOffsetBuilderDecorator extends EmailMessageDtoBuilderDecorator {
    private DateTime dateTime;

    public EmailMessageDtoSendDateOffsetBuilderDecorator(EmailMessageDtoBuilder builder, DateTime dateTime) {
        super(builder);
        this.dateTime = dateTime;
    }

    @Override
    public EmailMessageDto build() {
        EmailMessageDto dto = builder.build();
        dto.setSendDate(dateTime.toDate());
        return dto;
    }

    public EmailMessageDtoSendDateOffsetBuilderDecorator plusSeconds(int seconds){
        this.dateTime = this.dateTime.plusSeconds(seconds);
        return this;
    }
    public EmailMessageDtoSendDateOffsetBuilderDecorator plusMinutes(int minutes){
        this.dateTime = this.dateTime.plusMinutes(minutes);
        return this;
    }
    public EmailMessageDtoSendDateOffsetBuilderDecorator plusHours(int hours){
        this.dateTime = this.dateTime.plusHours(hours);
        return this;
    }

    public EmailMessageDtoSettingsBuilderDecorator next(){
        return new EmailMessageDtoSettingsBuilderDecorator(this);
    }
}
